package com.peanut.baby.mvp.point;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.peanut.baby.R;
import com.peanut.baby.model.PointRecord;
import com.peanut.devlibrary.adapter.HolderAdapter;

import java.util.List;

/**
 * Created by anonymouslystudio on 2017/8/7.
 */

public class RecordListAdapter extends HolderAdapter<PointRecord,RecordListAdapter.ViewHolder>{

    public RecordListAdapter(Context context, List<PointRecord> listData) {
        super(context, listData);
    }

    @Override
    public View buildConvertView(LayoutInflater layoutInflater, PointRecord pointRule, int position) {
        return inflate(R.layout.layout_item_point_rule);
    }

    @Override
    public ViewHolder buildHolder(View convertView, PointRecord pointRule, int position) {
        ViewHolder holder = new ViewHolder();
        holder.name = (TextView) convertView.findViewById(R.id.rule_name);
        holder.date = (TextView) convertView.findViewById(R.id.rule_desc);
        holder.value = (TextView) convertView.findViewById(R.id.rule_value);
        return holder;
    }

    @Override
    public void bindViewDatas(ViewHolder holder, PointRecord pointRule, int position) {
        holder.name.setText(pointRule.name);
        holder.date.setText(pointRule.date);
        holder.value.setText(pointRule.value);
        if(pointRule.isAdd){
            holder.value.setTextColor(context.getResources().getColor(R.color.text_green));
        }else{
            holder.value.setTextColor(context.getResources().getColor(R.color.colorPrimary));
        }

    }

    class ViewHolder{
        TextView    name;
        TextView    date;
        TextView    value;
    }
}
